package tests;

import common.Utils;
import org.openqa.selenium.By;

public class LoginPage extends Utils {
    public static String url = "http://139.196.34.232:8080/blog_login.html";

    public LoginPage() {
        super(url);
    }

    //检查页面是否登录成功
    //看登录界面的元素是否可以找到
    public void loginPageRight(){
        driver.findElement(By.cssSelector("body > div.container-login > div > h3"));
        driver.findElement(By.cssSelector("#username"));
    }

    //登录成功:输入正确账号密码
    //跳转到列表页面
    public void loginSuc() throws InterruptedException {
        driver.findElement(By.cssSelector("#username")).sendKeys("zhangsan");
        driver.findElement(By.cssSelector("#password")).sendKeys("123456");
        driver.findElement(By.cssSelector("#submit")).click();

//        Thread.sleep(2000);
        driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(1) > a"));
        String curl = driver.getCurrentUrl();
//        if(curl.equals("http://139.196.34.232:8080/blog_list.html") == false){
//            System.exit(1);
//        }
        //System.out.println(curl);
        assert (curl.equals("http://139.196.34.232:8080/blog_list.html") == true);

    }
    //TODO
    //登录失败:
    //用户名不存在,  密码错误,  账号或密码不能为空
    public void loginFail(){
    }
}
